export const findItem = (arr, deepKey, cb) => {
  const isDeep = !!deepKey
  arr = Array.prototype.slice.call(arr)
  let result = null
  function loop(arr) {
    for (let i = 0; i < arr.length; i++) {
      const item = arr[i]
      if (cb(item)) {
        result = item
        break
      }
      if (isDeep && item[deepKey] && item[deepKey].length) {
        loop(item[deepKey])
      }
    }
  }
  loop(arr)
  return result
}

export const flatten = () => {}
